package com.cnap.model.stage;

import cn.hutool.core.util.IdUtil;
import com.cnap.db.entity.StagePO;
import com.cnap.model.validator.EnumCheck;
import com.cnap.utils.JsonUtil;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

/**
 * 更新阶段状态
 *
 * @author xc
 **/
public class UpdateStageParam {
    /*
      云资源开通 extraInfo
      节点名称：  vmName
      节点规格：  vmSize

      k8s部署 extraInfo
      云商名称：  provider
      集群名称：  clusterName
     */


    // 服务id
    @NotNull
    private String svcId;
    // 类型
    @EnumCheck(enumClass = StageTypeEnum.class, message = "类型错误")
    private String type;
    // 额外信息
    private List<Map<String, String>> extraInfo;
    // 错误信息
    private String errorMsg;
    // 二级分类序号
    private int order;
    // 二级分类
    private String detailType;

    /**
     * 云商 public private
     */
    private String cloudScope;
    /**
     * cpu  gpu
     */
    private String arch;

    /**
     * get
     *
     * @return CloudScope
     */
    public String getCloudScope() {
        return cloudScope;
    }

    /**
     * set
     *
     * @param cloudScope cloudScope
     */
    public void setCloudScope(String cloudScope) {
        this.cloudScope = cloudScope;
    }

    /**
     * get
     *
     * @return Arch
     */
    public String getArch() {
        return arch;
    }

    /**
     * set
     *
     * @param arch arch
     */
    public void setArch(String arch) {
        this.arch = arch;
    }

    /**
     * get
     *
     * @return Order
     */
    public int getOrder() {
        return order;
    }

    /**
     * set
     *
     * @param order order
     */
    public void setOrder(int order) {
        this.order = order;
    }

    /**
     * get
     *
     * @return DetailType
     */
    public String getDetailType() {
        return detailType;
    }

    /**
     * set
     *
     * @param detailType detailType
     */
    public void setDetailType(String detailType) {
        this.detailType = detailType;
    }

    /**
     * get
     *
     * @return SvcId
     */
    public String getSvcId() {
        return svcId;
    }

    /**
     * set
     *
     * @param svcId svcId
     */
    public void setSvcId(String svcId) {
        this.svcId = svcId;
    }

    /**
     * get
     *
     * @return Type
     */
    public String getType() {
        return type;
    }

    /**
     * set
     *
     * @param type type
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * get
     *
     * @return ExtraInfo
     */
    public List<Map<String, String>> getExtraInfo() {
        return extraInfo;
    }

    /**
     * set
     *
     * @param extraInfo extraInfo
     */
    public void setExtraInfo(List<Map<String, String>> extraInfo) {
        this.extraInfo = extraInfo;
    }

    /**
     * get
     *
     * @return ErrorMsg
     */
    public String getErrorMsg() {
        return errorMsg;
    }

    /**
     * set
     *
     * @param errorMsg errorMsg
     */
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public String toString() {
        return JsonUtil.objectToJsonStr(this);
    }

    /**
     * 转换成po
     *
     * @return po
     */
    public StagePO toPO() {
        StagePO po = new StagePO();
        po.setId(IdUtil.simpleUUID());
        po.setServiceId(this.svcId);
        po.setType(this.type);
        po.setError(this.errorMsg);
        po.setExtraInfo(this.extraInfo);
        po.setOrder(this.order);
        po.setDetailType(this.detailType);
        po.setArch(this.arch);
        po.setCloudScope(this.cloudScope);
        return po;
    }
}
